<template>
  <div>
    <van-nav-bar>
      <template #title>
        <van-search
          v-model="value"
          placeholder="请输入小区或地址"
          @search="onSearch"
          class="inputBox"
        >
          <template #label>
            <div @click="local">
              {{ address }}<van-icon name="arrow-down" />
            </div>
          </template>
        </van-search>
      </template>
      <template #right>
        <div @click="$router.push('/mapFind')">
          <van-icon name="location-o" color="#fff" class="address" size="25" />
        </div>
      </template>
      <template #left>
        <div @click="onClickLeft">
          <van-icon name="arrow-left" color="#fff" class="address" size="25" />
        </div>
      </template>
    </van-nav-bar>
  </div>
</template>

<script>
export default {
  name: 'TopNavigation',
  props: {
    address: {
      type: String
    }
  },
  data () {
    return {
      value: ''
    }
  },
  methods: {
    onClickLeft () {
      this.$router.push('/')
    },
    onSearch () {
      this.value = ''
    },
    local () {
      this.$router.push('/cities')
    }
  }
}
</script>

<style lang="less" scoped>
.inputBox {
  z-index: 999;
  width: 225px;
  padding: 0;
  margin-right: 20px;
  border-radius: 5px;
}
</style>
